home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / src / GLperf3.12-src.lha / GLperf / Linear.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-01  |  2.7 KB  |  87 lines

  1. /*
  2. //   (C) COPYRIGHT International Business Machines Corp. 1993
  3. //   All Rights Reserved
  4. //   Licensed Materials - Property of IBM
  5. //   US Government Users Restricted Rights - Use, duplication or
  6. //   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. //
  8.  
  9. //
  10. // Permission to use, copy, modify, and distribute this software and its
  11. // documentation for any purpose and without fee is hereby granted, provided
  12. // that the above copyright notice appear in all copies and that both that
  13. // copyright notice and this permission notice appear in supporting
  14. // documentation, and that the name of I.B.M. not be used in advertising
  15. // or publicity pertaining to distribution of the software without specific,
  16. // written prior permission. I.B.M. makes no representations about the
  17. // suitability of this software for any purpose.  It is provided "as is"
  18. // without express or implied warranty.
  19. //
  20. // I.B.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  21. // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL I.B.M.
  22. // BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  23. // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  24. // OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  25. // CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  26. //
  27. // Author:  John Spitzer, IBM AWS Graphics Systems (Austin)
  28. //
  29. */
  30.  
  31. #include "Linear.h"
  32. #include <malloc.h>
  33.  
  34. void new_Linear(LinearPtr this)
  35. {
  36.     new_Vertex((VertexPtr)this);
  37.     this->SetState = Linear__SetState;
  38.     this->PixelSize = Linear__Size;
  39. }
  40.  
  41. void delete_Linear(TestPtr thisTest)
  42. {
  43.     delete_Vertex(thisTest);
  44. }
  45.  
  46. float Linear__Size(TestPtr thisTest)
  47. {
  48.     LinearPtr this = (LinearPtr)thisTest;
  49.     return this->size * this->lineWidth;
  50. }
  51.  
  52. int Linear__SetState(TestPtr thisTest)
  53. {
  54.     LinearPtr this = (LinearPtr)thisTest;
  55.     GLfloat windowDim;
  56.  
  57.     /* set parent state */
  58.     if (Vertex__SetState(thisTest) == -1) return -1;
  59.  
  60.     /* kick out if lines won't fit within window */
  61.     windowDim = (GLfloat)(min(this->environ.windowWidth, this->environ.windowHeight));
  62.     if (this->size >= windowDim) return -1;
  63.  
  64.     /* set own state */
  65.     if (!this->antiAlias) {
  66.         glDisable(GL_LINE_SMOOTH);
  67.     } else {
  68.     if (this->antiAlias == On) {
  69.         glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE);
  70.     } else {
  71.         glHint(GL_LINE_SMOOTH_HINT, this->antiAlias);
  72.     }
  73.         glEnable(GL_LINE_SMOOTH);
  74.     }
  75.  
  76.     glLineWidth(this->lineWidth);
  77.  
  78.     if (!this->lineStipple) {
  79.     glDisable(GL_LINE_STIPPLE);
  80.     } else {
  81.         /* In the future, we may want user defined stipple patterns */
  82.     glLineStipple(1, 0xf0f0);
  83.     glEnable(GL_LINE_STIPPLE);
  84.     }
  85.     return 0;
  86. }
  87.